package Map;

import java.util.ArrayList;
import java.util.List;

import Main.Constant;

public class Floor {
	int height, width;
	private List<Block> blocks = new ArrayList<Block>();
	public Floor(){
		
	}
	public Tile[][] getMap(int viewX,int viewY,int height,int width){
		Tile[][] tmpTile = new Tile[height][];
		for (int i = 0; i < tmpTile.length; i++) {
			tmpTile[i] = new Tile[width];
			for (int j = 0; j < tmpTile[i].length; j++)
				tmpTile[i][j] = new Tile();
		}
		for(Block block:getBlocks()){
			if(block.x>viewX||block.x<viewX+width||block.y>viewY||block.y<viewY+height){

				for (int _height = 0; _height < block.height; _height++)
					for (int _width = 0; _width < block.width; _width++)
						try {
							tmpTile[block.x + _height - viewX][block.y + _width- viewY] = new Tile(EnumTile.NORMAL);
						} catch (Exception e) {
						}
			}
		}
		return tmpTile;
	}
	public static void main(String[] args) {
		Floor mapa = new Floor();
		mapa.height = Integer.valueOf(1000);
		mapa.width = Integer.valueOf(1000);
		Block block = new Block();
		block.height=10;
		block.width=10;
		block.x=20;
		block.y=20;
		mapa.getBlocks().add(block);
		Tile[][] tile = mapa.getMap(0, 0,50,50);
		for (int i = 0; i < tile.length; i++) {
			for (int j = 0; j < tile[i].length; j++){
				System.out.print(tile[i][j].getType());
			}
			System.out.println();
		}
	}
	public List<Block> getBlocks() {
		return blocks;
	}
	public void setBlocks(List<Block> blocks) {
		this.blocks = blocks;
	}
}
